package com.wanyang.dto;

import cn.hutool.json.JSONUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;


@Data
public abstract class PostPublishBase {
    @ApiModelProperty(value = "新增不用传id，更新时传id")
    private Integer id;
    @ApiModelProperty(hidden = true)
    private Integer postCategoryId;
    @ApiModelProperty(hidden = true)
    private Integer areaId;
    @ApiModelProperty(value = "标题")
    private String title;
    @ApiModelProperty(hidden = true)
    private Integer publisherId;
    @ApiModelProperty(value = "是否发布，true发布，false草稿箱")
    private boolean isPublish;
    @ApiModelProperty(hidden = true)
    private String detail;


    @ApiModelProperty(hidden = true)
    public abstract Object getDetailObject();

    public boolean getIsPublish() {
        return isPublish;
    }

    public void setIsPublish(boolean publish) {
        isPublish = publish;
    }

    public void convertDetailAndCover() {
        Object detailObject = this.getDetailObject();
        if (detailObject != null)
            this.detail = JSONUtil.parse(detailObject).toString();

        // TODO cover
    }

    /**
     * 返回需要审核的内容
     *
     * @return
     */
    @ApiModelProperty(hidden = true)
    public abstract AuditObject getNeedAuditObject();

//    public abstract AuditObject getCovers(); TODO 这个有可能前端做，到时候确认一下

    public void afterPublish() {

    }

}
